<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>简途旅行</title>
    <meta name="format-detection" content="telephone=no" />
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/old/css/complain/adviceList.scss?__inline">
</head>
<body>
<div class="page-group" style="visibility: hidden">
    <div class="page page-current">
        <div data-toggle="scroller" data-type="js" class="page-content content infinite-scroll infinite-scroll-bottom" data-distance="30">
            <div class="header-wrapper">
                <img src="https://images.simpletour.com/activity/complain/advice_header.png" alt="">
            </div>
            <div class="header-title">
                <img src="https://images.simpletour.com/activity/complain/advice_title.png" alt="">
            </div>
            <div class="advice-lists">
                <div class="advice-wrapper">
                    <div class="userName"><i></i>王二毛说:</div>
                    <div class="advice">
                        <p>见图特别好,见图特别好见图特别好,见图特别好见图特别好,见图特别好见图特别好,见图特别好</p>
                        <div class="images">
                            <div class="img-wp">
                                <img src="" alt="">
                            </div>
                            <div class="img-wp">
                                <img src="" alt="">
                            </div>
                            <div class="img-wp">
                                <img src="" alt="">
                            </div>
                        </div>
                        <div class="bottom-btn">
                            <div class="cai">5</div>
                            <div class="zan">30</div>
                        </div>
                    </div>
                </div>

                <div class="advice-wrapper">
                    <div class="userName"><i></i>王二毛说:</div>
                    <div class="advice">
                        <p>见图特别好,见图特别好见图特别好,见图特别好见图特别好,见图特别好见图特别好,见图特别好</p>
                        <div class="bottom-btn">
                            <div class="cai">5</div>
                            <div class="zan">30</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/old/common/js/zepto.min.js"></script>
<script src="/old/common/js/scroll.js"></script>
<script src="/old/common/common/js/base.js"></script>
<!--<script src="/common/js/viewImg.js"></script>-->
<script>
    (function (doc, win) {

        var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    var style;
                    if (style = document.getElementById("forhtml")) {
                        style.parentNode.removeChild(style);
                    }
                    style = document.createElement("style");
                    style.id = "forhtml";
                    document.head.appendChild(style);
                    style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
                };
        recalc();
        doc.getElementsByClassName('page-group')[0].style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
    })(document, window);
    $(document).ready(function() {
        /* ============================================
         **********   旅客评价下拉加载更多  **************
         ============================================== */
        // 初始化图片预览
//        $('.comments').on('click','.img-wp',function() {
//            var viewsHtml = $(this).parent('.bottom-imgs').attr('data-images');
//            $.viewImg(viewsHtml.split(","),$(this).index());
//        });
        var loading = false;
        var indexFlag = 1;
        function addItems(data) {
            var strPackage = ' ';
            $.each(data, function (index, value) {
                var avatar = '';
                var starHtml = '<div class="stars"><ul>';
                for(var i = 0; i < value.score; i++) {
                    starHtml += '<li class="selected"></li>';
                }
                for (var j = 0; j < 5 - value.score; j++) {
                    starHtml += '<li></li>';
                }
                starHtml += "</ul></div>";
                if (!value.userAvatar){
                    avatar = '/images/avatar.png';
                }else {
                    avatar = value.userAvatar;
                }
                strPackage += '<div class="comment">' +
                        '<div class="title">' +
                        '<div class="avatar"><img src="' + avatar + '" alt=""></div>' +
                        '<div class="infos">' +
                        '<div class="userName">' + value.nickName + '</div>' +
                        '<div class="date">' + value.surveyTime + '</div>' +
                        '</div>' +
                        starHtml +
                        '</div>' +
                        '<div class="comment-content">' +
                        '<p>' + value.content + '</p>' +
                        '</div>';
                var imageHtml = '<div class="bottom-imgs" data-images="' + value.images + '">';
                if(value.imageCount > 4) {
                    for (var x = 0; x < 3; x++) {
                        imageHtml += '<div class="img-wp">' +
                                '<img src="'+value.images[x]+'!wechatQ3146146" alt="" /></div>';
                    }
                    imageHtml += '<div class="img-wp"><div class="more-cover"></div>'+
                            '<div class="more">共' + value.imageCount + '张</div>' +
                            '<img src="' + value.images[3] + '!wechatQ3146146" alt=""></div></div></div>';
                } else if(value.imageCount > 0 && value.imageCount <= 4) {
                    for (var y = 0; y < value.imageCount; y++) {
                        imageHtml += '<div class="img-wp">' +
                                '<img src="'+value.images[y]+'!wechatQ3146146" alt=""></div>';
                    }
                    imageHtml += '</div></div>';
                } else {
                    imageHtml = '</div></div>';
                }
                strPackage += imageHtml;
                if(value.isReply == 'true') {
                    strPackage += '<div class="serviceReply"><p><span>简途小简：</span>'+value.replyContent+'</p></div>';
                }
            });
            $('.comments').append(strPackage);
            $.refreshScroller();
        }
        function pull() {
            $.ajax({
                type: 'POST',
                url: '/mobile/gateway/wechat/tourism/survey',
                contentType:'application/json',
                data: JSON.stringify({
                    pageIndex: lastIndex,
                    pageSize: 10,
                }),
                success: function (data) {
                    if (data.code == 0) {
                        if (data.data.length == 0) {
                            $('#pullUp .pullUpLabel').text('没有更多了…');
                            $.refreshScroller();
                            if(indexFlag == lastIndex) {
                                $('.no-line').show();
                            } else {
                                $('.no-line').hide();
                            }
                        } else {
                            loading = false;
                            addItems(data.data);
                            $('#pullUp .pullUpLabel').text('下滑加载更多…');
                            lastIndex++;
                        }
                    } else if (data.code == 2) {
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        $.detachInfiniteScroll($('.infinite-scroll'));
                        // 删除加载提示符
                        $('.infinite-scroll-preloader').remove();
                    }
                },
                error: function () {
                    loading = false;
                }
            });
        }
        // 上次加载的序号
        var lastIndex = 1;
        // 注册'infinite'事件处理函数
        $(document).on('infinite', '.infinite-scroll-bottom',function() {
            // 如果正在加载，则退出
            if (loading) return;
            // 设置flag
            loading = true;
            pull();
        });
    });
</script>
</body>
</html>
